﻿using SF.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SF.Ucenter.mycenterusers
{
    public partial class payway : System.Web.UI.Page
    {
        Model.sf_user_info userInfo;
        string appWhere;
        BLL.sf_user_bank bll = new BLL.sf_user_bank();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                /*验证用户是否登录*/
                if (Session[DTKeys.SESSION_ADMIN_INFO] == null)
                {
                    Response.Redirect("index.aspx");
                }
                userInfo = Session[DTKeys.SESSION_ADMIN_INFO] as Model.sf_user_info;
                appWhere = Utils.getWhereByInfo(userInfo.busnieseNum, userInfo.appNum, userInfo.templatesNum);
                BindData();
                int action = Request["action"] == null ? 0 : Convert.ToInt32(Request["action"]);
                if (action != 0)
                {
                    switch (action)
                    {
                        case 1: Deladdr(Convert.ToInt32(Request["id"])); break;
                        default: break;
                    }
                }

            }
        }
        /// <summary>
        /// 绑定提现卡号 信息
        /// </summary>
        protected void BindData()
        {
            try
            {
                rptData.DataSource = bll.GetList(" userNum='" + userInfo.userNum + "' and "+appWhere);
                rptData.DataBind();
            }
            catch (Exception ex)
            {

            }
        }

        /// <summary>
        /// 删除地址
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected bool Deladdr(int id)
        {
            try
            {
                if (bll.Delete(id))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
}